package com.course.chapter6;


import java.util.ArrayList;
import java.util.Iterator;

public class CollectionDemo {

    public static void main(String[] args) {
        ArrayList<User> users = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            users.add(new User(i, "user" + i));
        }
        Iterator<User> iterator = users.iterator();
        while (iterator.hasNext()){
            User next = iterator.next();
                if("user6"==next.getName()){
                    iterator.remove();
                }
        }
    }
}
